/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifMantenimientoEncargo.java
 *
 * Created on 27/09/2010, 04:05:53 AM
 */

package Encargos;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.MiTablePrint;
import administracion.helper.Utiles_MensajesDialogo;
import administracion.helper.Utiles_PDF;
import administracion.helper.jPaginacion;
import com.jidesoft.hints.ListDataIntelliHints;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.ELProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;
import suministros.ejb30.TO.AnoTO;
import suministros.ejb30.TO.EmpresaTO;
import suministros.ejb30.TO.EncargoTO;
import suministros.ejb30.TO.MesTO;
import suministros.ejb30.TO.ParametrosConsultaTO;

/**
 *
 * @author Administrador
 */
public class jifMantenimientoEncargo extends javax.swing.JInternalFrame implements Observer {

    /** Creates new form jifMantenimientoEncargo */
    private ParametrosConsultaTO params;
    private jPaginacion panelPaginacion;
    private ListDataIntelliHints intelliHintsEmpresa;
    private List<EmpresaTO> empresas;
    private List<EncargoTO> encargos_encontrados;
    private JTableBinding jTableBinding;
    private BindingGroup bindingGroup;
    public jifMantenimientoEncargo(String titulo,boolean isAdministra) {
        super(titulo);
        this.panelPaginacion = new jPaginacion(this,15);

        initComponents();
        this.jbModificar.setEnabled(isAdministra);
        try {
             empresas = GestionPedidosDelegate.getInstance().obtenerEmpresas();
            this.cargaHintsIndependientes();
        } catch (Exception ex) {
            Logger.getLogger(jifMantenimientoEncargo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

      private void cargaHintsIndependientes() throws Exception {
         this.intelliHintsEmpresa = new ListDataIntelliHints(this.jtfRuc,empresas);
    }

    private ParametrosConsultaTO getParametrosConsulta(){
        String anio = null;
        String mes = null;
        String ruc = null;

        if(this.jcboAno.getSelectedIndex()>=0)
             anio = ((AnoTO)this.jcboAno.getSelectedItem()).getAno();
        if(this.jcboMes.getSelectedIndex()>=0)
             mes = ((MesTO)this.jcboMes.getSelectedItem()).getMes();
        if(this.jtfRuc.getText().trim().length()>0)
             ruc = this.jtfRuc.getText().trim();


            ParametrosConsultaTO parametros = new ParametrosConsultaTO();
            parametros.setAnio(anio);
            parametros.setMes(mes);
            parametros.setRuc_empresa(ruc);

             return parametros;
        }

     public void buscar(){
          try {
           params = getParametrosConsulta();
           int num_encargos_encontrados = GestionPedidosDelegate.getInstance().getNumeroDeEncargos(params);
           panelPaginacion.setTotalResultados(num_encargos_encontrados);
        } catch (Exception e) {
            Utiles_MensajesDialogo.mensajeError(e.getMessage());
        }
     }

     private void actualizaTablaEncargos(List<EncargoTO> encargos_encontrados) {
            this.bindingGroup = new BindingGroup();
            this.jTableBinding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ,encargos_encontrados , this.jtEncargos);

            JTableBinding.ColumnBinding columnBinding0 = this.jTableBinding.addColumnBinding(ELProperty.create("${empresa}"));

            columnBinding0.setColumnName("Empresa");
            columnBinding0.setColumnClass(String.class);
            columnBinding0.setEditable(false);

            JTableBinding.ColumnBinding columnBinding1= this.jTableBinding.addColumnBinding(ELProperty.create("${fecha_inicio}"));

            columnBinding1.setColumnName("Fecha Inicio");
            columnBinding1.setColumnClass(String.class);
            columnBinding1.setEditable(false);


            JTableBinding.ColumnBinding columnBinding2 = this.jTableBinding.addColumnBinding(ELProperty.create("${fecha_fin}"));

            columnBinding2.setColumnName("Fecha Fin");
            columnBinding2.setColumnClass(String.class);
            columnBinding2.setEditable(false);

            JTableBinding.ColumnBinding columnBinding3 = this.jTableBinding.addColumnBinding(ELProperty.create("${anio}"));

            columnBinding3.setColumnName("Año");
            columnBinding3.setColumnClass(String.class);
            columnBinding3.setEditable(false);

            JTableBinding.ColumnBinding columnBinding4 = this.jTableBinding.addColumnBinding(ELProperty.create("${mes}"));

            columnBinding4.setColumnName("Mes");
            columnBinding4.setColumnClass(String.class);
            columnBinding4.setEditable(false);

            JTableBinding.ColumnBinding columnBinding5 = this.jTableBinding.addColumnBinding(ELProperty.create("${observacion}"));

            columnBinding5.setColumnName("Observacion");
            columnBinding5.setColumnClass(String.class);
            columnBinding5.setEditable(false);

            this.bindingGroup.addBinding(this.jTableBinding);
            this.bindingGroup.bind();

        }

      private void buscarEncargos(){
        try{
            encargos_encontrados = GestionPedidosDelegate.getInstance().consultarEncargo(params,this.panelPaginacion.getPagActual(),this.panelPaginacion.getPagTamano());
            actualizaTablaEncargos(encargos_encontrados);
             if(encargos_encontrados.isEmpty()){
                 this.jbDetalles.setEnabled(false);
            }
            else{
                this.jbDetalles.setEnabled(true);
            }

        } catch (Exception ex) {
            Logger.getLogger(jifMantenimientoEncargo.class.getName()).log(Level.SEVERE, null, ex);
        }

     }


      private EmpresaTO getEmpresacodigo(String dni){
         EmpresaTO retorno = null;
        for (EmpresaTO empresa : this.empresas) {
          if (empresa.getRuc().equalsIgnoreCase(dni)) {
            retorno = empresa;
            break;
          }
        }
        return retorno;
    }

      private void buscarEmpresa()
      {
        EmpresaTO emp;
        if (this.jtfRuc.getText().trim().length() < 1) {
          try { emp = (EmpresaTO)this.intelliHintsEmpresa.getSelectedHint();
          } catch (NullPointerException ex) {
            emp = null;
          }
        } else {
          emp = this.getEmpresacodigo(this.jtfRuc.getText().trim());
        }
        if (emp == null) {
          Utiles_MensajesDialogo.mensajeError("La empresa no existe!");
          this.jtfRuc.setText("");
          emp = null;
        } else {
          this.jtfRazon.setText(emp.getRazon()+ " - " + emp.getRuc());
          this.jtfRuc.setText(emp.getRuc());
          buscar();


        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpOperativo = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jcboMes = new javax.swing.JComboBox();
        jbBuscar = new javax.swing.JButton();
        jtfRazon = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jcboAno = new javax.swing.JComboBox();
        jtfRuc = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtEncargos = new javax.swing.JTable();
        this.jtEncargos.getTableHeader().setReorderingAllowed(false) ;
        jbDetalles = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jbModificar = new javax.swing.JButton();
        jbtImprimir = new javax.swing.JButton();

        setIconifiable(true);

        jpOperativo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Busqueda Avanzada", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.Color.blue)); // NOI18N

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("Año");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("Mes");

        jcboMes.setFont(new java.awt.Font("Arial", 0, 12));
        jcboMes.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcboMesKeyPressed(evt);
            }
        });

        jbBuscar.setFont(new java.awt.Font("Arial", 0, 12));
        jbBuscar.setMnemonic('B');
        jbBuscar.setText("Buscar");
        jbBuscar.setToolTipText("Cancelar la Operacion");
        jbBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscarActionPerformed(evt);
            }
        });
        jbBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbBuscarKeyPressed(evt);
            }
        });

        jtfRazon.setFont(new java.awt.Font("Arial", 0, 12));
        jtfRazon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfRazonActionPerformed(evt);
            }
        });
        jtfRazon.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfRazonKeyPressed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel9.setText("EMPRESA");

        jLabel18.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel18.setText("RUC");

        jcboAno.setFont(new java.awt.Font("Arial", 0, 12));
        jcboAno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcboAnoActionPerformed(evt);
            }
        });

        jtfRuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfRucActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpOperativoLayout = new javax.swing.GroupLayout(jpOperativo);
        jpOperativo.setLayout(jpOperativoLayout);
        jpOperativoLayout.setHorizontalGroup(
            jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpOperativoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpOperativoLayout.createSequentialGroup()
                        .addComponent(jLabel18)
                        .addGap(18, 18, 18)
                        .addComponent(jtfRuc, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jtfRazon, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpOperativoLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 245, Short.MAX_VALUE)
                        .addComponent(jbBuscar)
                        .addGap(34, 34, 34)
                        .addComponent(jLabel1)
                        .addGap(33, 33, 33)
                        .addComponent(jcboAno, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel2)
                        .addGap(6, 6, 6)
                        .addComponent(jcboMes, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jpOperativoLayout.setVerticalGroup(
            jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpOperativoLayout.createSequentialGroup()
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(jtfRuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(4, 4, 4)
                .addGroup(jpOperativoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jcboAno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcboMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbBuscar))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Encargos Encontrados", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.Color.blue)); // NOI18N
        jPanel1.setLayout(new java.awt.BorderLayout());
        jPanel1.add(panelPaginacion,java.awt.BorderLayout.NORTH);

        jtEncargos.setAutoCreateRowSorter(true);
        jtEncargos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Empresa", "Fecha Inicio", "Fecha Fin", "Año", "Mes", "Observacion"
            }
        ));
        jScrollPane1.setViewportView(jtEncargos);

        jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jbDetalles.setFont(new java.awt.Font("Arial", 1, 12));
        jbDetalles.setMnemonic('D');
        jbDetalles.setText("VER DOCUMENTO");
        jbDetalles.setToolTipText("Cancelar la Operacion");
        jbDetalles.setEnabled(false);
        jbDetalles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbDetallesActionPerformed(evt);
            }
        });

        jbCancelar.setFont(new java.awt.Font("Arial", 1, 12));
        jbCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbCancelar.setMnemonic('C');
        jbCancelar.setText("CERRAR");
        jbCancelar.setToolTipText("Cancelar la Operacion");
        jbCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarActionPerformed(evt);
            }
        });
        jbCancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbCancelarKeyPressed(evt);
            }
        });

        jbModificar.setFont(new java.awt.Font("Arial", 1, 12));
        jbModificar.setText("MODIFICAR");
        jbModificar.setEnabled(false);
        jbModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbModificarActionPerformed(evt);
            }
        });

        jbtImprimir.setFont(new java.awt.Font("Arial", 1, 12));
        jbtImprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/document_print.png"))); // NOI18N
        jbtImprimir.setText("IMPRIMIR");
        jbtImprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtImprimirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jpOperativo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jbDetalles)
                            .addGap(43, 43, 43)
                            .addComponent(jbModificar)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtImprimir)
                            .addGap(18, 18, 18)
                            .addComponent(jbCancelar))
                        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 629, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jpOperativo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbDetalles)
                    .addComponent(jbModificar)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jbCancelar)
                        .addComponent(jbtImprimir))))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jcboMesKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcboMesKeyPressed

      /*  if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbBuscar.requestFocus();
        }*/
}//GEN-LAST:event_jcboMesKeyPressed

    private void jbBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscarActionPerformed
         buscar();
}//GEN-LAST:event_jbBuscarActionPerformed

    private void jbBuscarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbBuscarKeyPressed

      /*  if (evt.getKeyCode() == KeyEvent.VK_ENTER ){
            this.jbBuscar.doClick();
        }*/
}//GEN-LAST:event_jbBuscarKeyPressed

    private void jtfRazonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfRazonActionPerformed

        buscarEmpresa();
        // this.jcboFormaPago.requestFocus();
}//GEN-LAST:event_jtfRazonActionPerformed

    private void jtfRazonKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfRazonKeyPressed
        if (this.jtfRuc.getText().trim().length() > 0)
            this.jtfRuc.setText("");
}//GEN-LAST:event_jtfRazonKeyPressed

    private void jcboAnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboAnoActionPerformed

}//GEN-LAST:event_jcboAnoActionPerformed

    private void jtfRucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfRucActionPerformed
        if (this.jtfRuc.getText().trim().length() < 1)
            this.jtfRazon.requestFocus();
        else
             this.buscarEmpresa();
}//GEN-LAST:event_jtfRucActionPerformed

    private void jbDetallesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbDetallesActionPerformed
        int nro_comprobante;
        int filaElegida = this.jtEncargos.getSelectedRow();

        if (filaElegida < 0) {
            Utiles_MensajesDialogo.mensajeError("Debe elegir un Encargo");
            this.jtEncargos.requestFocus();
            return;
        }

        try {
            EncargoTO encargo = (EncargoTO)this.encargos_encontrados.get(this.jtEncargos.convertRowIndexToModel(filaElegida));
            byte[] archivo = GestionPedidosDelegate.getInstance().getEncargoArchivo(encargo.getId_encargo());
            //Reportes.verComprobante(cpto.getId_comprobante());
            ByteArrayInputStream is = new ByteArrayInputStream(archivo);
            Utiles_PDF.verArchivo(is);
           



        } catch (Exception e) {
            e.printStackTrace();
            Utiles_MensajesDialogo.mensajeError("No se pudo Cargar el archivo de comprobante\n" + e.getMessage());
        }
}//GEN-LAST:event_jbDetallesActionPerformed

    private void jbCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarActionPerformed

        this.dispose();
}//GEN-LAST:event_jbCancelarActionPerformed

    private void jbCancelarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbCancelarKeyPressed

}//GEN-LAST:event_jbCancelarKeyPressed

    private void jbModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbModificarActionPerformed
        int filaElegida = this.jtEncargos.getSelectedRow();

        if (filaElegida < 0) {
            Utiles_MensajesDialogo.mensajeError("Debe elegir un Encargo!");
            this.jtEncargos.requestFocus();
            return;
        }

        try {

            /*OrdenTO orden = (OrdenTO)this.ordenes_encontradas.get(this.jtOrdenes.convertRowIndexToModel(filaElegida));
            if(orden.getNro_solicitud_cotizacion().length()==0 && orden.getNro_licitacion().length()==0){
                //modificar orden
                jifRegistrarOrdenCompra modificarOrden=new jifRegistrarOrdenCompra(false);
                modificarOrden.setOrdenEdit(orden);
                modificarOrden.setLocation(this.dsk_padre.getWidth()/2 - modificarOrden.getWidth()/2 ,this.dsk_padre.getHeight()/2 - modificarOrden.getHeight()/2 - 20);
                this.dsk_padre.getDesktop().add( modificarOrden, javax.swing.JLayeredPane.DRAG_LAYER);
                modificarOrden.show();
                try {
                    modificarOrden.setSelected(true);
                } catch (java.beans.PropertyVetoException e2) {}
            } else
                Utiles_MensajesDialogo.mensajeError("No se admite modificar esta Orden");*/
        } catch (Exception e) {
            e.printStackTrace();
            Utiles_MensajesDialogo.mensajeError("No se pudo Cargar la Orden\n" + e.getMessage());
        }
}//GEN-LAST:event_jbModificarActionPerformed

    private void jbtImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtImprimirActionPerformed
        MiTablePrint pp = new MiTablePrint(this.jtEncargos, "ENCARGOS", "DETALLE DE ENCARGOS");
        pp.showPrintPreview();
    }//GEN-LAST:event_jbtImprimirActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbBuscar;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JButton jbDetalles;
    private javax.swing.JButton jbModificar;
    private javax.swing.JButton jbtImprimir;
    private javax.swing.JComboBox jcboAno;
    private javax.swing.JComboBox jcboMes;
    private javax.swing.JPanel jpOperativo;
    private javax.swing.JTable jtEncargos;
    private javax.swing.JTextField jtfRazon;
    private javax.swing.JTextField jtfRuc;
    // End of variables declaration//GEN-END:variables

    public void update(Observable o, Object arg) {
        buscarEncargos();
    }

}
